<?php

class Admin_SettingsController extends Zend_Controller_Action {

    public function init() {
        /* Initialize action controller here */
        $adminValidation = new Validations_User();
        $valid = $adminValidation->hasidentity();
        if ($valid) {
            if ($adminValidation->getUserTypeId() != 1) {
                $this->view->message = "You are not admin.";
                Zend_Auth::getInstance()->clearIdentity();
                $this->_redirect('/admin/login');
            }
        } else {
            $this->_redirect('/admin/login');
        }
        $this->_helper->layout->setLayout('admin');
    }

    public function indexAction() {        
        //get email api details
        $db = new Admin_Model_Api();
        $this->view->sendgridDetails = $db->getApiByName('sendgrid');    
        //get facebook api details
        $this->view->facebookDetails = $db->getApiByName('facebook');
    }

    public function usertypeaddAction() {
        $form = new Users_Form_UserTypeAdd();
        $this->view->form = $form;



//        if ($this->isRequest()->isPost()) {
//            if ($form->isValid($this->getRequest()->getPost())) {
//                $values = $form->getValues();
//                $newUserType = $values['usertype'];
//                $userTypeModel = new Users_Model_UserType();
//                $userTypeModel->createUserType(array(
//                    'type' => $newUserType
//                ));
//                $this->_redirect('/admin/settings/manage-user-type');
//            }
//        }
    }

}